import {
  getOptionProps
} from '@/utils/jsxPropsUtils'
import DraggableCard from '@/components/DraggableCard'
import OftenCard from '@/components/HomeCard/Often'
import CardConsumption from '@/components/HomeCard/CardConsumption'
import BookList from '@/components/HomeCard/BookList'
import Notice from '@/components/HomeCard/Notice'
import Paper from '@/components/HomeCard/Paper'
export default {
  name: 'DynamicRender',
  props: {
    setting: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    desktopId: {
      type: Number,
      default: -1
    },
    dataSource: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  render() {
    const {
      setting,
      dataSource
    } = getOptionProps(this)
    if (!dataSource['receptionFolderApplyList']) {
      dataSource['receptionFolderApplyList'] = []
    }
    if (dataSource && Number(dataSource.folderType) === 1) {
      return <OftenCard isDraggable={setting} dataSource={dataSource}/>
    }
    if (dataSource && Number(dataSource.folderType) === 2 && dataSource.cardId === 1) {
      return <CardConsumption vOn:delCard={this.$listeners.delAction} isDraggable={setting} dataSource={dataSource}/>
    }
    if (dataSource && Number(dataSource.folderType) === 2 && dataSource.cardId === 2) {
      return <BookList vOn:delCard={this.$listeners.delAction} isDraggable={setting} dataSource={dataSource}/>
    }
    if (dataSource && Number(dataSource.folderType) === 3) {
      return <DraggableCard vOn:delCard={this.$listeners.delAction} isDraggable={setting} dataSource={dataSource}/>
    }
    if (dataSource && Number(dataSource.folderType) === 4) {
      return <Notice isDraggable={setting} dataSource={dataSource}/>
    }
    if (dataSource && Number(dataSource.folderType) === 5) {
      return <Paper isDraggable={setting} dataSource={dataSource}/>
    }
    return <el-card>渲染出错</el-card>
  }
}
